<!DOCTYPE html>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="utf-8" %>
<%@ include file="./nav.jsp" %>
<div class="container-fluid">
    <div class="row">
        <div class="col-md-12">
            <img src="/img/stars.jpg" alt="..." class="note-img">
        </div>
       <div class="col-md-10 col-md-offset-1 note-type">
           ${notes.typeName}
           <div style="float:right;">
           <button class="note-edit" onclick="toCreate()">
               <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
           </button>
           </div>
       </div>


    </div>
    <div class="row">
        <div class="col-md-10 col-md-offset-1">

                <c:if test="${notes.topNotes!=null}">
                    <div class="top-line">置顶帖</div>
                    <c:forEach items="${notes.topNotes}" var="tn">
                        <div class="note-style">
                            <div style="float: left;margin-left: 20px">
                                <a href="${pageContext.request.contextPath}/api/note/note?noteid=${tn.noteId}"
                                   style="text-decoration: none;">
                                <h2>${tn.tittle}</h2>
                                </a>
                            </div>
                            <c:if test="${tn.good==true}">
                                <div class="note-good" style="color: #5cb85c;">精华帖</div>
                            </c:if>
                            <c:if test="${tn.top==true}">
                                <div class="note-good" style="color: #d17d22;">置顶帖</div>
                            </c:if>

                            <div style="float: right;margin-right: 20px;font-size: 20px">${tn.author.nickname}</div>
                        </div>
                    </c:forEach>
                </c:if>

                <c:if test="${notes.notes!=null}">
                    <div class="top-line">普通主题</div>
                    <c:forEach items="${notes.notes}" var="tn">
                        <div class="note-style">
                            <div style="float: left;;margin-left: 20px">
                                <a href="${pageContext.request.contextPath}/api/note/note?noteid=${tn.noteId}" style="text-decoration: none;">
                                    <h2>${tn.tittle}</h2>
                                </a>
                            </div>
                            <c:if test="${tn.good==true}">
                                <div class="note-good" style="color: #5cb85c;">精华帖</div>
                            </c:if>
                            <c:if test="${tn.top==true}">
                                <div class="note-good" style="color: #d17d22;">置顶帖</div>
                            </c:if>

                            <div style="float: right;margin-right: 20px;font-size: 20px">${tn.author.nickname}</div>
                        </div>
                    </c:forEach>
                </c:if>




        </div>
    </div>

</div>
<script type="text/javascript">
    function toCreate() {
        $.get("${pageContext.request.contextPath}/api/user/note/toCreate",function (data) {
            if (data.success==0){
                window.location.href="${pageContext.request.contextPath}/login.jsp";
            }else {
                window.location.href="${pageContext.request.contextPath}/api/user/note/toCreate";
            }

        })

    }
</script>
</body>
</html>
